package com.leadership.api.job;

import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.leadership.api.service.SurveyService;

@Component("surveyJob")
public class SurveyJob {
    
private static final Logger logger = LoggerFactory.getLogger(IdmJob.class);
    
    @Autowired
    private SurveyService surveyService;
    
    /**
     * run at 每一个小时的30分触发一次
     */
    @Scheduled(cron = "0 */24 * * * ?")
    public void scanSurveyItems() {
        
        logger.info("#scanSurveyItems() - start at {}", new Date());
        
        try {
            
            surveyService.syncItems();
            
        } catch (Exception e) {
            logger.error("#scanSurveyItems() - occur exception=[{}]", e);
        }
        
        logger.info("#scanSurveyItems() - finish at {}", new Date());
        
    }
    
}
